package com.dkha.task.contral;

import com.dkha.task.modual.entity.FaceTrackEntity;
import com.dkha.task.modual.mapper.SysUserTokenDao;
import com.dkha.task.service.FaceTrackService;
import com.dkha.task.service.WebSocketContral;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @version V1.0
 * @Description: TODO(please write your description)
 * All rights 成都电科慧安
 * @Title: TestContral
 * @Package com.dkha.task.contral
 * @author: panhui
 * @date: 2019/12/31 18:24
 * @Copyright: 成都电科慧安
 */
@RestController
@RequestMapping("/socket")
public class TestContral {

    @Autowired
    private WebSocketContral webSocketContral;

    @Autowired
    private SysUserTokenDao sysUserTokenDao;


    @Autowired
    private FaceTrackService faceTrackService;

    @GetMapping("/test1")
    public String test1(String token)
    {
        System.out.println("sysUserTokenDao="+sysUserTokenDao.getByToken(token,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())));
        webSocketContral.sendMessage("xxxxxxxxxxx");
        return "xxx";
    }


    @GetMapping("/test2")
    public String test2()
    {
        List<FaceTrackEntity> faceTrackEntities=new ArrayList<>();
        FaceTrackEntity faceTrackEntity=new FaceTrackEntity();
        faceTrackEntity.setTrajectoryThreshold(0.8);
        faceTrackEntity.setIdPortrait(111L);
        faceTrackEntities.add(faceTrackEntity);
        faceTrackService.saveBatch(faceTrackEntities);
        return "xxx";
    }
}
